﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Common.Particles
{
    public class FireworksParticleSystem2D : ParticleSystem2D
    {
        protected int m_maxParticleLife = 2000; //10 seconds
        protected int m_minParticleLife = 100; //1 second        

        protected int m_minXVelocity = -3;
        protected int m_minYVelocity = -4;

        protected int m_maxXVelocity = 3;
        protected int m_maxYVelocity = -2;

        protected int m_minXVelocityNoise = -2;
        protected int m_minYVelocityNoise = -0;

        protected int m_maxXVelocity_noise = 2;
        protected int m_maxYVelocity_noise = -0;

        protected bool m_particlesWithTrail;
        public bool ParticlesWithTrail
        {
            get { return m_particlesWithTrail; }
            set { m_particlesWithTrail = value; }
        }
     

        public FireworksParticleSystem2D(Texture2D texture, Vector2 position, bool hasTrail, int trailLength)
            : base (texture, position, hasTrail, trailLength)
        {
            m_updateFrequency = 50;
            m_nbParticlesPerUpdate = 4;
        }

        protected override void SetCurrentParticleParameters(ref Particle2D particle)
        {
            base.SetCurrentParticleParameters(ref particle);

            particle.Mass = Particle2D.m_defaultParticleMass;
            particle.HasTrail = m_particlesWithTrail;
            particle.Position = m_psPosition;
            particle.Life = m_random.Next(m_minParticleLife, m_maxParticleLife);
            particle.Velocity = new Vector2(m_random.Next(m_minXVelocity, m_maxXVelocity), m_random.Next(m_minYVelocity, m_maxYVelocity));
        }
    }
}
